<?php
// +---------------------------------------------------------------------------+
// | This file is part of the KnowledgebasePublisher package                   |
// | KnowledgebasePublisher - web based knowledgebase publisher tool           |
// |                                                                           |
// | Author:  Evgeny Leontev <eleontev@gmail.com>                              |
// | Copyright (c) 2005 Evgeny Leontev                                         |
// |                                                                           |
// | For the full copyright and license information, please view the LICENSE   |
// | file that was distributed with this source code.                          |
// +---------------------------------------------------------------------------+

require_once 'config.inc.php';
require_once 'common.inc.php';

session_name($conf['session_name']);
session_start();

$db =& DBUtil::connect($conf);

$reg =& Registry::instance();
$reg->setEntry('db', $db);
$reg->setEntry('tbl_pref', $conf['tbl_pref']);
$reg->setEntry('conf', $conf);


$nav = new AppNavigation;
$nav->setPage('index.php');
$nav->setEqualAttrib('GET', 'module');
$nav->setSubEqualAttrib('GET', 'page');
$nav->setTemplate(APP_TMPL_DIR . 'top_menu.html');

$nav->setMenuMsg(AppMsg::getMenuMsgs(false, 'top'));
$nav->setMenu('all');
$nav->setOption('target', 'main');

require_once APP_MODULE_DIR . 'setting/inc/SettingModel.php';
if(!SettingModel::getQuick(100, 'allow_contact')) {
	$nav->unsetMenuItem('feedback');
}


$controller = &new AppController();
$controller->self_page = 'index.php';
$priv = new AuthPriv();
$msg = &AppMsg::getMsgs('common_msg.ini', 'knowledgebase', false, false);


$tpl = new tplTemplatez(APP_TMPL_DIR . 'top_navigation.html');
$tpl->tplAssign('navigation', $nav->generate());
$tpl->tplAssign('username', $_SESSION['member_']['username']);
$tpl->tplAssign('client_view_link', $conf['client_home_path']);
$tpl->tplAssign('base_href', $conf['home_path']);
$tpl->tplAssign('meta_charset', $conf['lang']['meta_charset']);



// quick links
$range = array();
$range['nav'] = $msg['shortcuts_msg'];

if($priv->isPriv('insert', 'kb_entry')) {
	$link = $controller->getLink('knowledgebase', 'kb_entry', false, 'insert');
	$range[$link] = $msg['add_entry_msg'];
}

if($priv->isPriv('insert', 'kb_category')) {
	$link = $controller->getLink('knowledgebase', 'kb_category', false, 'insert');
	$range[$link] = $msg['add_category_msg'];
}

if($priv->isPriv('insert', 'kb_glossary')) {
	$link = $controller->getLink('knowledgebase', 'kb_glossary', false, 'insert');
	$range[$link] = $msg['add_glossary_msg'];		
}		

if($priv->isPriv('insert', 'file_entry')) {
	$link = $controller->getLink('file', 'file_entry', false, 'insert');
	$range[$link] = $msg['add_file_msg'];			
}		

if($priv->isPriv('insert', 'file_category')) {
	$link = $controller->getLink('file', 'file_category', false, 'insert');
	$range[$link] = $msg['add_file_category_msg'];	
}


$select = new FormSelect();
$select->select_tag = false;
$select->setRange($range);

$tpl->tplAssign('shortcut_select', $select->select());
$tpl->tplAssign($msg);


$tpl->tplParse();
echo $tpl->tplPrint(1);
?>